package zhaoyong.wang.tlias.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import zhaoyong.wang.tlias.pojo.Result;
import zhaoyong.wang.tlias.utils.ObsUpload;

import java.io.IOException;

@Slf4j
@RestController
public class UploadController {
    @Autowired
    private ObsUpload obsUpload;
    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException
    {
        log.info("文件上传:{}",image.getOriginalFilename());
        //调用华为云OBS
      String url=  obsUpload.upload(image);
        log.info("文件上传成功：{}",url);
        return Result.success(url);

    }
}
